const { app, screen, BrowserWindow } = require('electron');

const WindowApp = require('./window-app');

process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';



const createMainWindow = () => {
  const win = new WindowApp();
  win.listen();
  win.createWindow({
    isMainWin: true,
    width: 1200,
    height: 800,
    minWidth:750,
    minHeight: 620,
    movable: true,
  });
  win.createTray();

  const display = screen.getPrimaryDisplay()
  const { width, height } = display.bounds
  
  win.createWindow({
    isMainWin: false,
    width: 440,
    height: 104,
    minWidth:440,
    minHeight: 104,
    movable: true,
    resizable: false,
    alwaysOnTop: true,
    skipTaskbar: true,
    transparent: true,
    backgroundColor: '#00000000',
    route: '/clock',
    x: width - (440 + 20),
    y: 20
  });
}

app.whenReady().then(async () => {
  createMainWindow();

  app.on('activate', () => {
    if(BrowserWindow.getAllWindows().length === 0) {
      createMainWindow();
    }
  })
})

app.on('window-all-closed', () => {
  if(process.platform !== 'darwin') {
    app.quit();
  }
});